package com.ke.jdyd.util;

import android.content.Context;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.module.AppGlideModule;

import androidx.annotation.NonNull;

@GlideModule
public class GlideModuleConfig extends AppGlideModule {
  @Override
  public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
    //builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
    //配置内存缓存大小 1MB
    builder.setMemoryCache(new LruResourceCache(1024 * 1024));
    //配置图片池大小   1MB
    builder.setBitmapPool(new LruBitmapPool( 1024 * 1024));
    //设置磁盘缓存大小
    int size = 100 * 1024 * 1024;
    //设置磁盘缓存
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, size));
  }

}
